export const rules = {
  username: [
    { required: true, message: '请输入用户名', trigger: 'change' }
  ],
  password: [
    { required: true, message: '请输入密码', trigger: 'change' },
    { min: 8, message: '密码长度最少为8位', trigger: 'change' }
  ],
  verificationCode: [
    {
      validator: (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入验证码'))
        }
        if (!/^[\-]?\d{4,10}$/g.test(value)) {
          callback(new Error('请输入正确的验证码'))
        } else {
          callback()
        }
      },
      trigger: 'change'
    }
  ],
  code: [
    {
      validator: (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入图形验证码'))
        }
        if (!/^\w{4,10}$/g.test(value)) {
          callback(new Error('请输入正确的图形验证码'))
        } else {
          callback()
        }
      },
      trigger: 'change'
    }
  ]
}
